package com.yixun.qfbao.hander;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yixun.qfbao.api.service.PremisesApiService;
import com.yixun.qfbao.apidto.GetChooseM2PremisesFlagReqDto;
import com.yixun.qfbao.apidto.GetChooseM2PremisesFlagResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.GetChooseM2PremisesFlagReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;

/**
 * 判断是否M2楼盘	
 * 
 * @author jzliu
 *		
 */
@Service("getChooseM2PremisesFlagHander")
public class GetChooseM2PremisesFlagHander extends CommonAbstractHander {
	private static Logger logger= LoggerFactory.getLogger(GetChooseM2PremisesFlagHander.class);
	
	@Autowired
	private PremisesApiService premisesApiService;
	
	@SuppressWarnings("rawtypes")
	@Override
	public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
		GetChooseM2PremisesFlagReqVo req = (GetChooseM2PremisesFlagReqVo)reqDto;
		GetChooseM2PremisesFlagReqDto reqDto1 = req.getParams();
		BaseResponseDTO<GetChooseM2PremisesFlagResDto> res = new BaseResponseDTO<GetChooseM2PremisesFlagResDto>();
		GetChooseM2PremisesFlagResDto resDto = new GetChooseM2PremisesFlagResDto();
		try {
			if(StringUtils.isEmpty(reqDto1.getDomain()) && StringUtils.isEmpty(reqDto1.getCompanyUuid())){
				resDto.setResult(ResultEnum.FAIL.getNo());
				resDto.setResultMsg("未获取到开发商域名");
				res.setResData(resDto);
				res.setResult(resDto.getResult());
				return res;
			}
			resDto = premisesApiService.getChooseM2PremisesFlag(reqDto1);
		} catch (Exception e) {
			logger.error("GetChooseM2PremisesFlagHander error: {}", e);
			resDto.setResult(ResultEnum.FAIL.getNo());
			resDto.setResultMsg("判断是否M2楼盘失败!");
		}
		res.setResData(resDto);
		res.setResult(resDto.getResult());
		return res;
	}
	
}
